<template>
  <div>
    <!-- 推荐视频 -->
    <div class="tuijianshiping" v-for="item in tuijian" :key="item.id" @click="qukan(item)">
      <!-- 视频主页 -->
      <img :src="item.videoCover" alt="" />
      <!-- 视频信息 -->
      <span>{{ item.title }}</span>
    </div>
    <!-- 视频列表 -->
    <div class="shiping" v-for="item in wutuijian" :key="item.id" @click="qukan(item)">
      <!-- 视频信息 -->
      <div class="spxx">
        <span>{{ item.title }}</span>
      </div>
      <!-- 视频主页 -->
      <div class="sp">
        <img :src="item.videoCover" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "DianShitai",
  data() {
    return {
      tvData: [],
    };
  },
  computed: {
    // 推荐的视频
    tuijian() {
      let aaa = [];
      aaa = this.tvData.filter((item) => {
        return item.recommend == true;
      });
      return aaa;
    },
    //不是推荐的视频
    wutuijian() {
      let aaa = [];
      aaa = this.tvData.filter((item) => {
        return item.recommend != true;
      });
      return aaa;
    },
  },
  methods:{
    qukan(item){
       this.$router.push({
        name:'dianshitaineirong',
        params:{
          content:item
        }
      })
    }
  },
  mounted() {
    axios.get("http://localhost:8080/tv/tvall").then((res) => {
      this.tvData = res.data.data;
      console.log(this.tvData);
    });
  },
};
</script>

<style scoped>
.tuijianshiping {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0;
  border-bottom: 1px black solid;
  padding-bottom: 10px;
}
.tuijianshiping>img {
  width: 98%;
  margin-bottom: 10px;
}
.shiping {
  width: 100%;
  height: 90px;
  display: flex;
  flex-direction: row;
  align-items: center;
  margin: 10px 0;
  border-bottom: 1px black solid;
  padding-bottom: 10px;
  justify-content: space-between;
}
.spxx{
  width: 60%;
  height: 100%;
  display: flex;
  align-items: flex-start;
}
.sp{
  width:40%;
}
.sp>img {
  width: 100%;
  margin-bottom: 10px;
}
</style>
